import { ratedApi } from "@/api/api";

// 首页模块
const IndexModule = {
  namespaced: true,
  state() {
    return {
      // 最受欢迎数据
      ratedList: [],
    };
  },

  mutations: {
    // 改变最受欢迎列表
    getRatedList(state, payload) {
      state.ratedList = payload.result;
    },
  },
  actions: {
    // 异步获取最受欢迎列表数据
    asyncGetRatedList({ commit }) {
      return new Promise((resolve, reject) => {
        ratedApi().then((res) => {
          resolve();
          commit("getRatedList", res);
        });
      });
    },
  },
};

export default IndexModule;
